---
category: Random
created: '2020-05-05'
title: Generate a random boolean
updated: '2021-10-13'
---

**JavaScript version**

```js randomBoolean.js
const randomBoolean = () => Math.random() >= 0.5;
```

**TypeScript version**

```ts randomBoolean.ts
const randomBoolean = (): boolean => Math.random() >= 0.5;
```
